<template>
  <div class="app-tree">
    <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
  </div>
</template>
<script>
import {findGridTree} from '@/http/AppApi'
export default {
  name: 'app-grid-tree',
  props: {},
  mounted () {
    this.getTreeData()
  },
  data () {
    return {
      treeData: [],
      defaultProps: {
        label: 'name',
        children: 'children'
      }
    }
  },
  methods: {
    getTreeData () {
      findGridTree().then(data => {
        if (data) {
          this.treeData = data
        }
      })
    },
    handleNodeClick (data) {
      this.$emit('appTreeClick', data)
    }
  }
}
</script>
<style>
.app-tree {
  padding: 15px 0px 0px 10px;
  height: 500px;
}
</style>
